$(document).ready(
		function(){
			//initialize dropdown list of mainCategory
			$('#mainCategory').css('width', '200');
			$('#mainCategory').change(mainCategoryChanged);
			$('#subCategory').css('width', '200');
			var request = $.ajax({
					url : '/index.php/category/load',
					data : {categoryType:1},
					dataType:'json'}
					);
			request.done(
					function(data, textStatus, jqXHR){
						if (textStatus=="success"){
							var mainCategory = $('#mainCategory');					
							$('#mainCategory').empty();					
							if(mainCategory.prop) {								
								var options = mainCategory.prop('options');								
							}								
							else {								
								var options = mainCategory.attr('options');								
							}
							$.each(data, function(index, value){
								//alert(index);alert(value);
								options[options.length+1] = new Option(value['ArticleCategoryName'],value['ArticleCategoryId']);
							});			
						}
				});
//			need to debug style
//			$('#mainCategory').selectmenu();			
//			$('#subCategory').selectmenu();
			}
		);

function mainCategoryChanged(){
	var mainCategorySelected = $("#mainCategory option:selected").val();
	var request1 = $.ajax({
		url:'/index.php/category/load',
		data : {categoryType:2,mainCategory:mainCategorySelected},
		dataType:'json'
	});
	request1.error(function(jqXHR, textStatus){
		alert("Request failed: " + jqXHR.responseText);
	});
	request1.done(function(data,textStatus,jqXHR){
		if(textStatus == "success"){
			var subCategory = $('#subCategory');
			subCategory.empty();
			if(subCategory.prop){
				var options = subCategory.prop('options');	
			}
			else {								
				var options = subCategory.attr('options');								
			}
			$.each(data, function(index, value){
				//alert(index);alert(value);
				options[options.length+1] = new Option(value['ArticleCategoryName'],value['ArticleCategoryId']);
			});		
		}
	});
	jQuery.ajax(request1);
}



		